<?php

namespace app\controller;

use app\logic\WorkOrderLogic;
use think\App;
use think\response\View;

class WorkOrder extends Base
{
    /**
     * @var WorkOrderLogic
     */
    private WorkOrderLogic $workOrderLogic;

    /**
     * @param App $app
     * @param WorkOrderLogic $workOrderLogic
     */
    public function __construct(App $app, WorkOrderLogic $workOrderLogic)
    {
        parent::__construct($app);
        $this->workOrderLogic = $workOrderLogic;
    }

    public function index(): View
    {
        $typeOption = $this->workOrderLogic->getTypeOption();
        $priorityOption = $this->workOrderLogic->getPriorityOption();
        return view('index', [
            'type_option'     => $typeOption,
            'priority_option' => $priorityOption
        ]);
    }

    public function page()
    {
        $params = $this->request->get();
        $list = $this->workOrderLogic->getList($params);
        return $this->success($list);
    }
}